<?php
/*
 * Created on 04/06/2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class AppController extends Controller{
 	var $helpers = array('Form', 'Html', 'Javascript', 'Time','Session');
	var $components = array('Cookie','Session','Email');
	var $uses = array();
	function __construct(){
		parent::__construct();
	}
	function verificaLogado(){
		$user = $this->Session->read('User.username');
		if($user == ''){
			$this->redirect('/logins/logins');
		}
	}
	function configuraEmail(){
		$port = Configure::read('port');
		$server = Configure::read('email_server');
		$timeout = Configure::read('timeout');
		$username = Configure::read('email_user');
		$password = Configure::read('email_password');
		$from = Configure::read('from');
		if($server != ''){
			$this->Email->smtpOptions = array(
				'port'=>$port,
				'timeout'=>$timeout,
			    'host' => $server,
				'username'=>$username,
				'password'=>$password
			);
			$this->Email->delivery = 'smtp';
			$this->Email->from = $from;
			$this->Email->sendAs = 'html';
		}
	}
	function inicilizaAction($func,$action,$controller){
 		$this->inicializaLocale();
 		$this->AccessControl->getAccess($func,$this->Session,$controller);
		$this->setMenu();
	}
	function setMenu(){
 		$this->set('data',$this->MainMenu->find('threaded',array('orders'=>'position','conditions'=>array('users_id' => $this->Session->read('User.id'))) )); 
	}
 	function setDadosElementos($act){
	}
 	function inicializaLocale(){
		Configure::write('Config.language',$this->Cookie->read('Config.language'));
 	}
 }
?>
